package com.example.Map;

public class Test {
    public static void main(String[] args) {
        //method();

//        //在JDK5之前，会把所有的数据都先放到一个数组中
//        //我们自己定义的方法，形参只要写一个数组就可以了
//        int[] arr = {1, 2, 3, 4, 5};
//        int sum = getSum(arr);
//        System.out.println(sum);    //15

/*
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(arr);//[I@3b6eb2ec
        getSum();//[I@1e643faf
*/

        int sum = getSum(1, 2, 3, 4, 5);
        System.out.println(sum);    //14

    }

    private static int getSum(int number, int... arr) {
//        System.out.println(arr);
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }

    private static int getSum1(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }

    private static void method() {
        int a = 10;
        int b = 20;
        int c = 30;
        int sum1 = getSum(a, b);
        System.out.println(sum1);
        int sum2 = getSum(a, b, c);
        System.out.println(sum2);
    }

    private static int getSum(int a, int b) {
        return a + b;
    }

    private static int getSum(int a, int b, int c) {
        return a + b + c;
    }
}
